﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NEmu.MemoryPages
{
    public sealed class BufferPage : MemoryPage
    {
        private byte[] m_Memory;

        public BufferPage(ulong size)
        {
            m_Memory = new byte[size];
        }

        public override byte Read(ulong address)
        {
            if (address >= (ulong)m_Memory.LongLength)
                return 0;

            return m_Memory[address];
        }

        public override void Write(ulong address, byte value)
        {
            if (address >= (ulong)m_Memory.LongLength)
                return;

            m_Memory[address] = value;
        }

        public override ulong Size
        {
            get { return (ulong)m_Memory.LongLength; }
        }

        public override void Clear()
        {
            Array.Clear(m_Memory, 0, m_Memory.Length);
        }

        public override void Dispose()
        {
            return;
        }
    }
}
